<?php

require_once $GLOBALS['ROO'] . 'Languages/' . $_SESSION[$SESSLG] . '/lang.default.mex';
require_once 'class.compliance.php';

$AMLCheck = new Compliance();

if (!is_numeric($_POST['FraCargo'])) {
    $print = '<div class="Error">Confirme o valor da Taxa</div>';
} else {

    $Dup = $AMLCheck->DuplicateBlock($_POST['OBJCTCL'], $_POST['OBJCTRC'], $_POST['FraEnviado']);
    if ($Dup) {
        $printmsg = "alert('Remessa Duplicada - A remessa " . $Dup . " tem os mesmos dados.');";
    } else {
        echo '<div id="Prc_Loader" class="Line"><img src="_response/bin.php?get=extjs/default/shared/blue-loading.gif" /></div>';
        $AML = $AMLCheck->AMLVerify(1,'SenderID', $_POST['OBJCTCL'], $__sys['Country'], $_POST['FraEntregue'], 1);

        if ($AML[0] > 0) {
            if ($AML['Flag'] > 0) {
                //=== Output ALERT
                $printmsg = "
                document.getElementById('Prc_Loader').innerHTML='';
		if(confirm('" . $lang['XFK0WK2A'][$AML['AML_MSGTYPE']] . "')==true) {
		document.InvoiceProperties.AMLCHECK.value = {$AML['AMLCHECK']};
		document.InvoiceProperties.AMLTYPE.value = {$AML['AMLTYPEID']};
		document.InvoiceProperties.AMLDOCREQ.value = '{$AML['AMLDOCREQ']}}';
		document.InvoiceProperties.AMLDESCR.value = '{$AML['AMLDESCR']}';
		document.InvoiceProperties.AML_alert.value = {$AML['Flag']};
		document.InvoiceProperties.PRSVOR.value = 'Executar Ordem';
                document.getElementById('RC').innerHTML='';
		document.InvoiceProperties.action = '_response/call.php?get=Operative/opv_transfernew';
		subform('InvoiceProperties','ORResponse');
		} else {
		document.InvoiceProperties.PRSVOR.disabled = false;
		}";
            } else {
                //=== No ALERT
                $printmsg = "document.InvoiceProperties.AMLCHECK.value = {$AML['AMLCHECK']};
		document.InvoiceProperties.AMLTYPE.value = {$AML['AMLTYPEID']};
		document.InvoiceProperties.AMLDESCR.value = '{$AML['AMLDESCR']}';
		document.InvoiceProperties.AML_alert.value = {$AML['Flag']};
		document.InvoiceProperties.PRSVOR.value = 'Executar Ordem';
                document.getElementById('RC').innerHTML='';
		document.InvoiceProperties.action = '_response/call.php?get=Operative/opv_transfernew';
		subform('InvoiceProperties','ORResponse');";
            }
        } elseif ($AML[0] == 0) {
            //=== Proceed NO ERRORS
            $printmsg = "document.InvoiceProperties.AMLCHECK.value = 0;
		document.InvoiceProperties.PRSVOR.value = 'Executar Ordem';
                document.getElementById('RC').innerHTML='';
		document.InvoiceProperties.action = '_response/call.php?get=Operative/opv_transfernew';
		subform('InvoiceProperties','ORResponse');";
        }
    }
}
echo "<script charset='utf-8' type=\"text/javascript\">" . $printmsg . "</script>";
?>
